package model;

import java.util.ArrayList;

import javax.swing.JOptionPane;

import communication.Alarm;
import communication.AlarmListener;
import communication.FireAlarm;
import communication.GasAlarm;
import communication.RadiationAlarm;

/**
 * Monitor class
 * @author Adrien Ledeul
 * @version 0.1
 */
public class Monitor implements AlarmListener
{
	protected ArrayList<AlarmLog> log;
	protected Set set;
	
	/**
	 * Constructors
	 * 
	 */
	public Monitor(Set set) 
	{
		this.log = new ArrayList<AlarmLog>();
		this.set = set;
	}
	
	/**
	 * Getters & Setters
	 * 
	 */
	public ArrayList<AlarmLog> getLog() 
	{
		return log;
	}
	
	/**
	 * Alarm receiver
	 * @param alarm Alarm
	 */
	@Override
	public void receiveAlarm(Alarm alarm) 
	{
		String TypeTxt = "Alarm";
		if(alarm instanceof FireAlarm) 
			TypeTxt = "New Fire Alarm!";
		else if(alarm instanceof GasAlarm) 
			TypeTxt = "New Gas Alarm!";
		else if(alarm instanceof RadiationAlarm) 
			TypeTxt = "New radiation Alarm!";
		JOptionPane.showMessageDialog(null, TypeTxt, "New Alarm!", JOptionPane.INFORMATION_MESSAGE);
	}
}
